<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\DbConnection\Model\Model;
/**
 * @property int $id 
 * @property int $user_id
 * @property string $channel_id
 * @property string $request_id 
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 */
class VideoCallAudit extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'video_call_audit';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    /**
     * 增加发起审核日志
     * @param string $channelId
     * @param string $requestId
     * @return bool
     */
    public function addAuditRequestLog($userId, string $channelId, string $requestId)
    {
        $model = new self();

        $model->user_id    = $userId;
        $model->channel_id = $channelId;
        $model->request_id = $requestId;

        return $model->save();
    }

    /**
     * @param string $requestId
     * @return \Hyperf\Database\Model\Builder|\Hyperf\Database\Model\Model|object|null
     */
    public function getRequestLog(string $requestId)
    {
        return self::where(['request_id' => $requestId])->first();
    }

    /**
     * @param string $requestId
     * @return \Hyperf\Database\Model\Builder|\Hyperf\Database\Model\Model|object|null
     */
    public function getChannelLog(string $channelId)
    {
        return self::where(['channel_id' => $channelId])->first();
    }
}
